package org.deadline.service.baseapp;

import java.util.List;
import org.deadline.model.baseapp.UserApplicationConfiguration;
import org.deadline.repository.baseapp.UserApplicationConfigurationRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class UserApplicationConfigurationServiceImpl implements UserApplicationConfigurationService {

	@Autowired
    UserApplicationConfigurationRepository userApplicationConfigurationRepository;

	public long countAllUserApplicationConfigurations() {
        return userApplicationConfigurationRepository.count();
    }

	public void deleteUserApplicationConfiguration(UserApplicationConfiguration userApplicationConfiguration) {
        userApplicationConfigurationRepository.delete(userApplicationConfiguration);
    }

	public UserApplicationConfiguration findUserApplicationConfiguration(Long id) {
        return userApplicationConfigurationRepository.findOne(id);
    }

	public List<UserApplicationConfiguration> findAllUserApplicationConfigurations() {
        return userApplicationConfigurationRepository.findAll();
    }

	public List<UserApplicationConfiguration> findUserApplicationConfigurationEntries(int firstResult, int maxResults) {
        return userApplicationConfigurationRepository.findAll(new org.springframework.data.domain.PageRequest(firstResult / maxResults, maxResults)).getContent();
    }

	public void saveUserApplicationConfiguration(UserApplicationConfiguration userApplicationConfiguration) {
        userApplicationConfigurationRepository.save(userApplicationConfiguration);
    }

	public UserApplicationConfiguration updateUserApplicationConfiguration(UserApplicationConfiguration userApplicationConfiguration) {
        return userApplicationConfigurationRepository.save(userApplicationConfiguration);
    }
}
